import request from '@/utils/request'

export function getMenu(pageIndex, pageSize, menuName, needPage) {
  return request({
    url: '/menu/all',
    method: 'get',
    params: { pageIndex, pageSize, menuName, needPage }
  })
}

export function getLevelMenu(menuType,pageIndex, pageSize, needPage) {
  return request({
    url: '/menu/level/' + menuType,
    method: 'get',
    params: { pageIndex, pageSize, needPage }
  })
}

export function insertMenu(data) {
  return request({
    url: '/menu/menu',
    method: 'post',
    data
  })
}

export function updateMenu(data) {
  return request({
    url: '/menu/menuId',
    method: 'put',
    data
  })
}

export function deleteMenu(menuId) {
  return request({
    url: '/menu/' + menuId,
    method: 'delete',
    params: { menuId }
  })
}

export function selectByType(pageIndex, pageSize, menuType) {
  return request({
    url: '/menu/level/' + menuType,
    method: 'get',
    params: { pageIndex, pageSize }
  })
}

export function insertPermission(roleId,menuIdList) {
  return request({
    url: '/menu/permission/' + roleId,
    method: 'post',
    params: { menuIdList }
  })
}